package com.example.demo06resource.config;

import com.example.demo06resource.component.UserComponent;
import com.example.demo06resource.listener.HelloApplicationRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author wangxun
 */
@Configuration
@ConditionalOnProperty(prefix = "user", name = "enable", havingValue = "true")
public class ResourceConfiguration {

    @Bean
    @ConditionalOnClass(value = HelloApplicationRunner.class)
    @ConditionalOnBean(value = HelloApplicationRunner.class)
    public UserComponent userComponent() {
        return new UserComponent();
    }
}
